(function(w){
var g = {};

var globadata = {
  lunbo:[{
      imgpath1:'../image/banner.jpg',
      imgpath2:'../image/banner2.jpg',
      imgpath3:'../image/banner3.jpg',
  }],
//最新项目数据
zxxm:[
        {id:1 ,title: '招中挖(10~20吨)师傅',dizhi:'济南天桥区北园大街',miaoshu:'市政府项目',gongqi:'1',renshu:'15',juli:'1.58',time:'1' },
        {id:2 ,title: '招中挖(10~20吨)师傅',dizhi:'济南天桥区北园大街',miaoshu:'市政府项目',gongqi:'1',renshu:'15',juli:'1.58',time:'1' },
        {id:3 , title: '招中挖(10~20吨)师傅',dizhi:'济南天桥区北园大街',miaoshu:'市政府项目',gongqi:'1',renshu:'15',juli:'1.58',time:'1' },
        {id:4 , title: '招中挖(10~20吨)师傅',dizhi:'济南天桥区北园大街',miaoshu:'市政府项目',gongqi:'1',renshu:'15',juli:'1.58',time:'1' },
        ],
//成功项目数据
cgxm:[
        {id:1 ,title: '招中挖(10~20吨)师傅',dizhi:'鲁能康桥',miaoshu:'市政府项目',gongqi:'1',renshu:'15',juli:'1.58',time:'1' },
        {id:2 , title: '招中挖(10~20吨)师傅',dizhi:'鲁能康桥',miaoshu:'市政府项目',gongqi:'1',renshu:'15',juli:'1.58',time:'1' },
        {id:3 ,title: '招中挖(10~20吨)师傅',dizhi:'鲁能康桥',miaoshu:'市政府项目',gongqi:'1',renshu:'15',juli:'1.58',time:'1' },
        {id:4 , title: '招中挖(10~20吨)师傅',dizhi:'鲁能康桥',miaoshu:'市政府项目',gongqi:'1',renshu:'15',juli:'1.58',time:'1' },
      ],

//历史搜索数据
lishi: [
        {id:1 ,title: '招中挖(10~20吨)师傅' },
        {id:2 ,title: '招中挖(10~20吨)师傅' },
        {id:3 ,title: '招中挖(10~20吨)师傅' },
        ],
// 热搜关键词
reso:[
        {id:4,title:'机手'},
        {id:5,title:'北园大街'},
        {id:6,title:'济洛路'},
        {id:8,title:'二环东路'},
        {id:9,title:'盖家沟'},
        {id:10,title:'腊山立交桥'},
        {id:6,title:'八一立交桥'},
        {id:8,title:'邢村立交桥'},
        {id:9,title:'堤口路'},
        {id:10,title:'长盛小区'},
      ],
// 项目需求页面数据
xmxq: [
        { id: 1, title: '1招中挖(10~20吨)师傅', dizhi: '1济南天桥区北园大街', miaoshu: '市政府项目', gongqi: '1', renshu: '3', juli: '1.58', time: '1'},
        { id: 2, title: '2招中挖(10~20吨)师傅', dizhi: '济南天桥区北园大街', miaoshu: '市政府项目', gongqi: '2', renshu: '4', juli: '1.58', time: '1'},
        { id: 3, title: '3招中挖(10~20吨)师傅', dizhi: '济南天桥区北园大街', miaoshu: '市政府项目', gongqi: '3', renshu: '3', juli: '1.58', time: '1'},
        { id: 4, title: '4招中挖(10~20吨)师傅', dizhi: '济南天桥区北园大街', miaoshu: '市政府项目', gongqi: '2', renshu: '15', juli: '1.58', time: '1'},
        { id: 5, title: '5招中挖(10~20吨)师傅', dizhi: '济南天桥区北园大街', miaoshu: '市政府项目', gongqi: '1', renshu: '5', juli: '1.58', time: '1'},
        { id: 6, title: '6招中挖(10~20吨)师傅', dizhi: '济南天桥区北园大街', miaoshu: '市政府项目', gongqi: '1', renshu: '2', juli: '1.58', time: '1'},
        { id: 7, title: '7招中挖(10~20吨)师傅', dizhi: '济南天桥区北园大街', miaoshu: '市政府项目', gongqi: '5', renshu: '6', juli: '1.58', time: '1'},
        { id: 8, title: '8招中挖(10~20吨)师傅', dizhi: '济南天桥区北园大街', miaoshu: '市政府项目', gongqi: '1', renshu: '2', juli: '1.58', time: '1'},
        { id: 9, title: '9招中挖(10~20吨)师傅', dizhi: '济南天桥区北园大街', miaoshu: '市政府项目', gongqi: '1', renshu: '1', juli: '1.58', time: '1'},
        { id: 10, title: '10招中挖(10~20吨)师傅', dizhi: '济南天桥区北园大街', miaoshu: '市政府项目', gongqi: '1', renshu: '1', juli: '1.58', time: '1'},
      ],
      ////综合服务
      //拖车
tuoche:   [

            ],
    //加油
jiayou:   [

                  ],
                  //维修
weixiu:   [

                        ],
  //综合服务详情
  showtc: [
          {zxxm:'美瑞特挖掘机维修，10年挖掘机维修经验，100余名挖掘机修理技师，价值300万的挖掘机维修设备。1500台∕次挖掘机维修案例，擅长卡特、小松、日立、沃尔沃、现代等等。',fwtp1:'../../image/banner.jpg',fwtp2:'../../image/banner2.jpg',fwtp3:'../../image/banner3.jpg',touxiang:'../../image/banner2.jpg',name:'王师傅',dizhi:'济南市天桥区北园大街',juli:'4.58',dianhua:'10010'},
        ],
  //遍历历史记录
  lishi:   [
          {id:1 ,title: '招中挖(10~20吨)师傅' },
          {id:2 ,title: '招中挖(10~20吨)师傅' },
          {id:3 ,title: '招中挖(10~20吨)师傅' },
        ],
   reso:[
     {id:4,title:'蓝叠'},
     {id:5,title:'蓝叠蓝叠蓝叠蓝叠'},
     {id:6,title:'蓝叠蓝叠'},
     {id:8,title:'蓝叠'},
     {id:9,title:'蓝叠蓝叠蓝叠蓝叠蓝叠'},
     {id:10,title:'蓝叠蓝叠'},
     {id:6,title:'蓝叠蓝叠'},
     {id:8,title:'蓝叠'},
     {id:9,title:'蓝叠蓝叠蓝叠蓝叠蓝叠'},
     {id:10,title:'蓝叠蓝叠'},
   ],
   //机手列表
   jishou:   [
           {id:1 ,title: '',jialing:'5',type:'中大挖',tijian:'6186',fuwu:'1727',haoping:'100',img:'../../image/ns.jpg',icon:true },
          {id:2 ,title: '李师傅',jialing:'3',type:'中挖',tijian:'4265',fuwu:'891',haoping:'99',img:'../../image/ns.jpg',icon:false },
           {id:3,title: '金师傅',jialing:'5',type:'中大挖',tijian:'3546',fuwu:'1727',haoping:'100',img:'../../image/ns.jpg',icon:true },
            {id:4 ,title: '韩师傅',jialing:'3',type:'中挖',tijian:'4212',fuwu:'819',haoping:'99',img:'../../image/ns.jpg',icon:true },
         ],
//机手详情
renwu:   [

        {id:1 ,title: '',nianling:'26岁',jialing:'5年',type:'中大挖',img:'../../image/ns.jpg',icon:true ,text:"现在已有五年的工作经验，驾驶技术娴熟，无不良驾驶记录，无重大交通事故以及责任违章；具有较强的安全以及，为人踏实，老实忠厚。性格开朗，大方。"},

      ],
      xinwen:   [



            ],
zhengshu:[
 {id:1,img:"../../image/certificate_1.jpg",alt:1},
 {id:2,img:"../../image/certificate_2.jpg",alt:2},
 {id:3,img:"../../image/certificate_3.jpg",alt:3},
  {id:3,img:"../../image/certificate_3.jpg",alt:3},
],
zonghepingfen:[
{pinfen:5.00,title:"准时率",gaodi:"高于同行",bilv:"1.52%"},
{pinfen:5.00,title:"完成质量",gaodi:"高于同行",bilv:"1.43%"},
{pinfen:5.00,title:"服务态度",gaodi:"高于同行",bilv:"1.15%"},
],
guzhupingjia:[
{id:1,img:"../../image/ns.jpg", time:"2019-03-30",text:"专业水平高，驾驶技术娴熟，交付准时，严谨认真", type: 'A' },
{id:2,img:"../../image/ns.jpg", time:"2019-02-18",text:"准点率高、沟通顺畅、服务态度很好",type: 'C'},
 {id:3,img:"../../image/ns.jpg", time:"2019-01-16",text:"驾驶技术娴熟，很好，合作很愉快", type: 'B'},
   {id:4,img:"../../image/ns.jpg", time:"2018-09-28",text:"已经是第二次合作了，服务很不错，期待继续合作",type: 'C'},
],
//个人中心
//参与项目
joinitem: [],
//我的会员卡
carditem: [
               {id:1 ,name:"我自是年少",kahao:"156101021963;",img:"../../image/ns.jpg",ewm:"../../image/er.png"}

             ],
//我的积分
jflist1:[
  {id:1,title:"签到成1功",time:"2019-04-12",number:"+150"},
{id:2,title:"邀请注册",time:"2019-04-11",number:"+150"},
  {id:3,title:"分享送积分",time:"2019-04-10",number:"+100"},
    {id:4,title:"积分兑换",time:"2019-04-08",number:"-1200"},


],
jflist2:[
  {id:1,title:"签到2成功",time:"2019-04-12",number:"+150"},
{id:2,title:"邀请注册",time:"2019-04-11",number:"+150"},
  {id:3,title:"分享送积分",time:"2019-04-10",number:"+100"},
    {id:4,title:"积分兑换",time:"2019-04-08",number:"-1200"},
      {id:5,title:"签到成功",time:"2019-04-04",number:"+100"},

],
jflist3:[
  {id:1,title:"签到3成功",time:"2019-04-12",number:"+150"},
{id:2,title:"邀请注册",time:"2019-04-11",number:"+150"},
  {id:3,title:"分享送积分",time:"2019-04-10",number:"+100"},
    {id:4,title:"积分兑换",time:"2019-04-08",number:"-1200"},
      {id:5,title:"签到成功",time:"2019-04-04",number:"+100"},
        {id:6,title:"签到成功",time:"2019-04-02",number:"+150"},
],
//我的评价
zonghepingjia: [
        {id:1 ,fenshu:"5.00",type:"准时率",gaodi:"高于同行",bilv:"1.52%", },
          {id:2 ,fenshu:"5.00",type:"完成质量",gaodi:"高于同行",bilv:"1.43%",},
        {id:3 ,fenshu:"5.00",type:"服务态度",gaodi:"低于同行",bilv:"1.15%",},

      ],
      guzhupingjia: [
              {id:1 ,img:"../../image/Boyfriend.jpg",name:"buzhidao",time:"2019-03-30",text:"专业水平高，驾驶技术娴熟，交付准时，严谨认真", type: 'A'},
                {id:2 ,img:"../../image/Boyfriend.jpg",name:"daobuzhi",time:"2019-02-18",text:"准点率高、沟通顺畅、服务态度很好",type: 'C' },
              {id:3 ,img:"../../image/Boyfriend.jpg",name:"zhibudao",time:"2019-01-16",text:"驾驶技术娴熟，很好，合作很愉快",type: 'B' },
{id:4 ,img:"../../image/Boyfriend.jpg",name:"mark",time:"2018-09-28",text:"已经是第二次合作了，服务很不错，期待继续合作", type: 'C'},

            ],


};

// 获取数据

g.getdata = function(){
  var ret = api.getPrefs({
      key: 'globadata',
      sync: true
      });

    if (ret == '') {
      console.log('没有数据');
      api.setPrefs({
          key: 'globadata',
          value: JSON.stringify(globadata)
      });
      return globadata;
    }else {

     return JSON.parse(ret);
    }


}
//
// 设置数据 使用方法 在更新数据后使用 $tools.setData('字段',[数据类型]);

g.setData = function(key,value){


      var gbdata = this.getdata();
      var data = Object.assign({},gbdata[key],value);
         gbdata[key]=data;

        api.setPrefs({
             key: 'globadata',
             value: JSON.stringify(gbdata),
         });
  // 注册数据修改通知
      api.sendEvent({
          name: 'datarefresh',
          extra: {
              key:key ,
              value: value
          }
      });


}
//
// //注册监听事件 使用方法 在apireaday内调用 $tools.datarefresh(list);
g.datarefresh =function(vm){

      api.addEventListener({
          name: 'datarefresh'
      }, function(ret, err){
          if( ret ){
      var key = ret.value.key;
      var data =Object.assign({},vm.key,ret.value.value);
      vm.key = data;

          }else{
            console.log(JSON.stringify( err ));
          }
      });




}
//
//
//
//es6 兼容

if (typeof Object.assign != 'function') {
        Object.assign = function(target) {
            'use strict';
            if (target == null) {
                throw new TypeError('Cannot convert undefined or null to object');
            }
            target = Object(target);
            for (var index = 1; index < arguments.length; index++) {
                var source = arguments[index];
                if (source != null) {
                    for (var key in source) {
                        if (Object.prototype.hasOwnProperty.call(source, key)) {
                            target[key] = source[key];
                        }
                    }
                }
            }
            return target;
        };
        /*获取界面的js并重新执行 eval()*/
        var s_code = document.getElementsByTagName('script'),code_index=0;
        for (var i = 0, len = s_code.length; i < len; i++) {
            if (s_code[i] && s_code[i].innerHTML.indexOf("Object.assign") != '-1') {
                code_index = i;
            }
        }
        if(code_index){eval(s_code[code_index].innerHTML); }
}

// es6兼容结束
//清楚缓存
// api.removePrefs({
//     key: 'globadata'
// });
w.$tools = g;
})(window)
